class Solution {
public: vector<vector<int>> result;
      vector<int>path;
      void backtracking(int n, int k, int index)
      {
          if (path.size() == k)
          {
              result.push_back(path);
              return;
          }
          for (int i = index; i <= n - (k - path.size()) + 1; i++)
          {
              path.push_back(i);
              backtracking(n, k, i + 1);
              path.pop_back();
          }

      }
      vector<vector<int>> combine(int n, int k) {
          result.clear();
          path.clear();
          backtracking(n, k, 1);
          return result;



      }
}; class Solution {
public:
    vector<vector<int>> result;
    vector<int>path;
    void backtreacking(int k, int n, int sum, int index)
    {
        if (path.size() == k)
        {
            if (sum == n)
            {
                result.push_back(path);
                return;




            }
            else
                return;
        }
        for (int i = index; i <= 9 - (k - path.size()) + 1; i++)
        {
            path.push_back(i);
            sum += i;
            backtreacking(k, n, sum, i + 1);
            sum -= i;
            path.pop_back();
        }




    }



    vector<vector<int>> combinationSum3(int k, int n) {
        result.clear();
        path.clear();
        backtreacking(k, n, 0, 1);
        return result;



    }
}; class Solution {
public:
    const string map[10] = { " "," ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz", };
    vector<string>result;
    string path;


    void backtracking(string& digits, int index)
    {
        if (path.size() == digits.size())
        {
            result.push_back(path);
            return;




        }
        int dig = digits[index] - '0';

        string str = map[dig];
        for (int i = 0; i < str.size(); i++)
        {
            path.push_back(str[i]);
            backtracking(digits, index + 1);
            path.pop_back();
        }
    }
    vector<string> letterCombinations(string digits) {
        result.clear();
        path.clear();
        if (digits.size() == 0)
            return result;
        backtracking(digits, 0);
        return result;




    }
}; class Solution {
public:
    vector<vector<int>>  result;
    vector<int>path;
    void backtracking(vector<int>& candidates, int target, int sum, int index)
    {
        if (sum > target)
            return;

        if (sum == target)
        {
            result.push_back(path);
            return;




        }
        for (int i = index; i < candidates.size(); i++)
        {
            path.push_back(candidates[i]);
            sum += candidates[i];
            backtracking(candidates, target, sum, i);
            path.pop_back();
            sum -= candidates[i];
        }









    }






    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        result.clear();
        path.clear();
        backtracking(candidates, target, 0, 0);
        return result;
    }
}; class Solution {
public:
    vector<vector<int>> result;
    vector<int>path;
    void backtracking(vector<int>& candidates, int target, int sum, int index, vector<int>& used)
    {
        if (sum == target)
        {
            result.push_back(path);
            return;
        }
        for (int i = index; i < candidates.size(); i++)
        {
            if (i > 0 && candidates[i] == candidates[i - 1] && used[i - 1] == 0)
                continue;
            path.push_back(candidates[i]);
            sum += candidates[i];
            used[i] = 1;
            backtracking(candidates, target, sum, i + 1, used);
            sum -= candidates[i];
            used[i] = 0;
            path.pop_back();
        }




    }
    vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {
        result.clear();
        path.clear();
        sort(candidates.begin(), candidates.end());
        vector<int>used(candidates.size(), 0);
        backtracking(candidates, target, 0, 0, used);
        return result;

    }
};
class Solution {
public:
    vector<vector<int>> result;
    vector<int>path;
    void backtracking(vector<int>& nums, int index)
    {
        result.push_back(path);
        if (index > nums.size())
            return;
        for (int i = index; i < nums.size(); i++)
        {
            path.push_back(nums[i]);
            backtracking(nums, i + 1);
            path.pop_back();
        }





    }







    vector<vector<int>> subsets(vector<int>& nums) {
        result.clear();
        path.clear();
        backtracking(nums, 0);
        return result;







    }
}; class Solution {
public:
    vector<vector<int>> result;
    vector<int>path;
    void backtracking(vector<int>& nums, int index, vector<int>used)
    {
        result.push_back(path);
        if (index > nums.size())
            return;
        for (int i = index; i < nums.size(); i++)
        {
            if (i > 0 && nums[i] == nums[i - 1] && used[i - 1] == 0)
                continue;

            path.push_back(nums[i]);
            used[i] = 1;
            backtracking(nums, i + 1, used);
            used[i] = 0;
            path.pop_back();
        }









    }
    vector<vector<int>> subsetsWithDup(vector<int>& nums) {
        result.clear();
        path.clear();
        sort(nums.begin(), nums.end());
        vector<int>used(nums.size(), 0);
        backtracking(nums, 0, used);
        return result;






    }
}; class Solution {
public:
    vector<vector<int>> result;
    vector<int>path;
    void backtracking(vector<int>& nums, int index)
    {
        if (path.size() > 1)
            result.push_back(path);


        int used[201] = { 0 };
        for (int i = index; i < nums.size(); i++)
        {
            if (!path.empty() && nums[i] < path.back() || used[nums[i] + 100] == 1)
                continue;
            path.push_back(nums[i]);
            used[nums[i] + 100] = 1;
            backtracking(nums, i + 1);

            path.pop_back();
        }







    }
    vector<vector<int>> findSubsequences(vector<int>& nums) {
        result.clear();
        path.clear();
        backtracking(nums, 0);
        return result;



    }
};